package com.stemaini.utility;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

/**
 *
 * @author Adhik' 2007 bo...
 */
public class PanelImage extends JPanel
{
    private BufferedImage bufImage;
    private Image Image;
    
    /** Creates a new instance of PanelImage */
    public PanelImage(File fileInput) throws IOException
    {
        bufImage = ImageIO.read(fileInput); 
        Image = bufImage;
        this.repaint(); 
    }
    
    public PanelImage(URL input) throws IOException
    {
        bufImage = ImageIO.read(input);
        Image = bufImage;
        this.repaint(); 
    }
    
        
    @Override
    public void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        g2.drawImage(Image, 0, 0, 
                    bufImage.getWidth(), bufImage.getHeight(), null);

    }
    
}
